package com.liyuhan.onlinetaxibackground.Util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

// redis连接池工具类
public class JedisPoolUtils {

    private static JedisPool jedisPool;

    static {
        // 设置JedisPoolConfig
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(1000);
        config.setMaxIdle(50);

        //初始化JedisPool
        jedisPool = new JedisPool(config, "127.0.0.1", Integer.parseInt("6379"));
    }

    /**
     * 获取连接方法
     */
    public static Jedis getJedis() {
        return jedisPool.getResource();
    }
}
